using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAO;
using System.Data;

namespace BUS
{
    /// <summary> 
    ///Author: nnamthach@gmail.com 
    /// <summary>
    public class TVC_CATE2Control
    {
        #region Local Variable
        private TVC_CATE2DataAccess _objDAO;
        #endregion Local Variable

        #region Method
        public TVC_CATE2Control()
        {
            _objDAO = new TVC_CATE2DataAccess();
        }

        public TVC_CATE2Info Get(string db,
        String maingroup,
        ref string sErr)
        {
            return _objDAO.Get(db,
            maingroup,
            ref sErr);
        }

        public DataTable GetAll(string db,
        ref string sErr)
        {
            return _objDAO.GetAll(db,
            ref sErr);
        }


        public Int32 Add(TVC_CATE2Info obj, ref string sErr)
        {
            return _objDAO.Add(obj, ref sErr);
        }

        public string Update(TVC_CATE2Info obj)
        {
            return _objDAO.Update(obj);
        }

        public string Delete(string db,
        String maingroup
        )
        {
            return _objDAO.Delete(db,
            maingroup
            );
        }
        public Boolean IsExist(string db,
        String maingroup
        )
        {
            return _objDAO.IsExist(db,
            maingroup
            );
        }


        public string InsertUpdate(TVC_CATE2Info obj)
        {
            string sErr = "";
            if (IsExist(obj.db,
            obj.maingroup
            ))
            {
                sErr = Update(obj);
            }
            else
                Add(obj, ref sErr);
            return sErr;
        }

        public DataTable GetTransferOut(string dtb, object from, object to, ref string sErr)
        {
            return _objDAO.GetTransferOut(dtb, from, to, ref sErr);
        }

        public DataTable ToTransferInStruct()
        {
            return TVC_CATE2Info.ToDataTable();
        }

        public string TransferIn(string db, DataRow row)
        {
            TVC_CATE2Info inf = new TVC_CATE2Info(row)
            {
                db = db
            };
            return InsertUpdate(inf);
        }
        #endregion Method

        public object BeginTransaction(ref string sErr)
        {
            return _objDAO.BeginTransaction(ref sErr);
        }

        public bool CommitTransaction(ref string sErr)
        {
            return _objDAO.CommitTransaction(ref sErr);
        }

        public bool RollbackTransaction(ref string sErr)
        {
            return _objDAO.RollbackTransaction(ref sErr);
        }

        public bool SetTransaction(object trans)
        {
            return _objDAO.SetTransaction(trans);
        }
    }
}
